<!DOCTYPE html>
<html>
<head>
  <title>数据结构表添加</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="../bootstrap4/css/bootstrap.min.css">
  <link rel="stylesheet" href="../css2/style2.css"> 
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
  <script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
  <script src="../js2/my.js"></script>
</head>

<script type="text/javascript">
$(function(){
	$("#formID").validate({
        rules: { 
            "datatabEname": {
                required: true
            },
            "datatabCname": {
                required: true
            },
            "dataEname": {
                required: true
            },
            "dataCname": {
                required: true
            },
            "dataType": {
                required: true
            } 
        },
        messages:{
             
            "datatabEname": {
                required: "表名字段不能为空"
            },
            "datatabCname": {
                required: "表名不能为空"
            },
            "dataEname": {
                required: "字段不能为空"
            },
            "dataCname": {
                required: "字段名不能为空"
            },
            "dataType": {
                required: "类型（输入，选择）不能为空"
            }
        },
        submitHandler:function(form){
        	$.ajax({
        		type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url: "saveDatagroupdInfo" ,//url
                data: $('#formID').serialize(),
                success: function (result) {
                    console.log(result);//打印服务端返回的数据(调试用)
                    if (result.code == 200) {
                        if(confirm(result.msg+'是否继续？？'))
                        {   
                        	 window.location.href = "addDatagroupdInfo";
                        }
                        else
                        {  
                        	 window.location.href = "queryForDatagroupdInfoList";
                        }
                    }
                    else{                	
                    	alert(result.msg);
                    }
                     
                },
                error : function() {
                    alert("异常！");
                }
            });
        },
        //自定义错误样式
        errorClass:"text-danger",
        //未通过验证,进行高亮处理或其他处理；
        highlight:function(input){
            $(input).closest(".form-group").addClass("has-error");
        },
        //通过验证,清除高亮效果或其他处理；
        unhighlight:function(input){
            $(input).closest(".form-group").removeClass("has-error");
        }
	});
});

</script>
<body>
<div class="header-area" id="headerArea">
   <div class="container h-100 d-flex align-items-center justify-content-between">
 
     <div class="logo-wrapper">
     <a th:href="@{queryForDatagroupdInfoList}"> 返回 </a>
	 </div>
     <!-- Search Form-->
     <div class="top-search-form">
      	 数据结构表添加
     </div>
     <div  id="suhaNavbarToggler"><span></span><span></span><span></span></div>
   </div>
 </div>

<div class="container mt60">
  <form id="formID"  >
  	<input type="hidden" name="dataId" th:value="${datagroupdInfoVO?.dataId}" /> 
    <div class="form-group">
       <div class="single-payment-method"> 
       		<img class="mb-3" src="../img/bg-img/16.jpeg"   width="100%"alt="">
       </div>
    </div>
   
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="datatabEname" class="fl" >表名字段:</label>
      <input type="text" class="form-control" id="datatabEname" placeholder="请填写表名字段" 
      name="datatabEname"
      th:value="${datagroupdInfoVO?.datatabEname}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="datatabCname" class="fl" >表名:</label>
      <input type="text" class="form-control" id="datatabCname" placeholder="请填写表名" 
      name="datatabCname"
      th:value="${datagroupdInfoVO?.datatabCname}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="dataEname" class="fl" >字段:</label>
      <input type="text" class="form-control" id="dataEname" placeholder="请填写字段" 
      name="dataEname"
      th:value="${datagroupdInfoVO?.dataEname}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="dataCname" class="fl" >字段名:</label>
      <input type="text" class="form-control" id="dataCname" placeholder="请填写字段名" 
      name="dataCname"
      th:value="${datagroupdInfoVO?.dataCname}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="dataType" class="fl" >类型（输入，选择）:</label>
      <select id="dataType" name="dataType" class="form-control" placeholder="请选择类型"   >
			<option value="1" selected>输入</option>
			<option value="2">数字</option> 
			<option value="3">选择</option>  
	 </select>
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="dataStore" class="fl" >选择范围入库:</label>
      <input type="text" class="form-control" id="dataStore" placeholder="请填写选择范围入库" 
      name="dataStore"
      th:value="${datagroupdInfoVO?.dataStore}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="dataShow" class="fl" >选择范围展示:</label>
      <input type="text" class="form-control" id="dataShow" placeholder="请填写选择范围展示" 
      name="dataShow"
      th:value="${datagroupdInfoVO?.dataShow}" >
    </div>
    <div class="form-group"> 
      <label class="title fl"></label>
      <label for="dataLimit" class="fl" >输入界值:</label>
      <input type="text" class="form-control" id="dataLimit" placeholder="请填写输入界值" 
      name="dataLimit"
      th:value="${datagroupdInfoVO?.dataLimit}" >
    </div>
 
     <button type="submit" class="btn btn-primary btn-block" >提交</button>
  </form>
 
</div>

</body>
</html>
